<?php

require_once('/opt/app/apipoolsdk/php/ApiPool.php');

function RunTest($service, $params, $display_debug = false)
{
    $response = new ApiPoolResponse();

    ApiPool::setRequestSrc("tangguo");
    $api_pool = new ApiPool();

    $api_pool->setServer("10.241.12.117", 10006);
    $api_pool->setDefaultParams(array('platform'=>'web'));

                ob_start();
                $response = $api_pool->request($service, $params, 10000000000);
		$debuginfo = ob_get_contents();
                ob_clean();
	if (!empty($debuginfo))
		var_dump($debuginfo); 

    if( $display_debug ) {
        echo "############### debug info ###############\n";
        echo "--------------len:".strlen($response->getAppDebugInfo())."----------------------------\n";
        echo $response->getAppDebugInfo();
        echo "------------------------------------------\n\n";
    }
    if( $response->getError() !== null ) {
        echo "ApiPool System Errno:" .$response->getError(). "\n";
        echo "ApiPool System Error:" .$response->getErrorInfo(). "\n";
        return false;
    }
    
    if( $response->getAppErrorCode() != 0 ) {
        $app_error_code = $response->getAppErrorCode();
        $app_error_info = $response->getAppErrorInfo();
        echo "ApiPool Service Errno:$app_error_code\n";
        echo "ApiPool Service Error:$app_error_info\n";   
        return false;
    } 
    //$data = $response->getAppData();
    $data = $response->getResult();
    if( $display_debug ) {
        echo "############## response data #############\n";
        echo "--------------len:".strlen($data)."----------------------------\n";
        echo $data, "\n";
        echo "------------------------------------------\n\n";
    }

    return $response->getAppData();
}

//$data = RunTest('Relation.getRelationType',array('sdid' => '123', 'sdids'=>'456,789', 'judge_type'=>1), true);
